<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="/css/pintuer.css">
    <link rel="stylesheet" href="/css/admin.css">
    <script src="/js/jquery.js"></script>
    <script src="/js/pintuer.js"></script>
    <script src="/js/vuejs-2.5.16.js"></script>
    <script src="/js/axios-0.18.0.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="/element-ui/lib/index.js"></script>

</head>
<body>
<div class="panel admin-panel" id="moviesListDiv">
    <div class="panel-head"><strong class="icon-reorder">选项列表</strong>
    </div>
    <div class="padding border-bottom">
        <form>
            <ul class="search" style="padding-left:10px;">
                <li><a class="button border-main icon-plus-square-o" :href="'/option_add.html?id='+id"> 添加选项</a></li>
            </ul>
        </form>
    </div>
    <table class="table table-hover text-center">
        <tr>
            <th width="10%">编号</th>
            <th width="10%">选项内容</th>
            <th width="10%">分值</th>
            <th width="25%">创建时间</th>
            <th width="25%">更新时间</th>
            <th width="310px">操作</th>
        </tr>

        <tr v-for="(option,index) in pagination.items">
            <td style="text-align:center; padding-left:20px;">{{index+1}}</td>
            <td>{{option.content}}</td>
            <td>{{option.score}}</td>
            <td>{{option.created}}</td>
            <td>{{option.updated}}</td>
            <td>
                <div class="button-group">
                    <a class="button border-main" :href="'./option_add.html?optionId='+option.id"><span class="icon-edit"></span>修改</a>
                    <a class="button border-red" href="javascript:void(0)" @click="deleteById(option.id)">
                        <span class="icon-trash-o"></span>删除</a>
                </div>
            </td>
        </tr>

        <tr>
            <td colspan="8">
                <!--分页组件-->
                <div class="block">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="pagination.page"
                            :page-size="pagination.pagesize"
                            :total="pagination.counts"
                            background
                            layout="prev, pager, next"
                    >
                    </el-pagination>
                </div>
            </td>
		</tr>
    </table>
</div>
<script type="text/javascript">
    const app = new Vue({
        el: '#moviesListDiv',
        data: {
            cid:"",
            keyword:"",
            moviesList:[],
            ids:[],
            pagination:{},
            id:""
        },
        methods: {
            handleSizeChange(pagesize){
                this.pagination.pagesize=pagesize
                this.findList()
            },
            handleCurrentChange(page){
                this.pagination.page=page
                this.findList()
            },
            deleteById(optionId) {
                if(window.confirm("确定要删除吗？")){
                axios.get('soul/option/deleteById?id=' + optionId).then(resp=>{
                        this.findList();
                })}
            },
            findList() {
                this.id = location.search.split("=")[1];
                axios.get('soul/option/' + this.id , {
                    params: {
                        "page": this.pagination.page,
                        "pagesize": this.pagination.pagesize,

                    }
                }).then(resp => {
                    this.pagination = resp.data;
                })
            }
        },
        created(){
            this.findList();
        }
    })
</script>
<script src="/js/verify.js"></script>
</body>
</html>